﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using ChinaSoft.Model;
namespace ChinaSoft.BLL
{
	/// <summary>
	/// BLL_tb_MidSoft_PmFlowNode
	/// </summary>
	public partial class BLL_tb_MidSoft_PmFlowNode
	{
		private readonly ChinaSoft.DAL.DAL_tb_MidSoft_PmFlowNode dal=new ChinaSoft.DAL.DAL_tb_MidSoft_PmFlowNode();
		public BLL_tb_MidSoft_PmFlowNode()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int PmFlowNodeId)
		{
			return dal.Exists(PmFlowNodeId);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int PmFlowNodeId)
		{
			
			return dal.Delete(PmFlowNodeId);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string PmFlowNodeIdlist )
		{
			return dal.DeleteList(PmFlowNodeIdlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode GetModel(int PmFlowNodeId)
		{
			
			return dal.GetModel(PmFlowNodeId);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode GetModelByCache(int PmFlowNodeId)
		{
			
			string CacheKey = "Model_tb_MidSoft_PmFlowNodeModel-" + PmFlowNodeId;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(PmFlowNodeId);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode> DataTableToList(DataTable dt)
		{
			List<ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode> modelList = new List<ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ChinaSoft.Model.Model_tb_MidSoft_PmFlowNode();
					if(dt.Rows[n]["PmFlowNodeId"]!=null && dt.Rows[n]["PmFlowNodeId"].ToString()!="")
					{
						model.PmFlowNodeId=int.Parse(dt.Rows[n]["PmFlowNodeId"].ToString());
					}
					if(dt.Rows[n]["PmFlowId"]!=null && dt.Rows[n]["PmFlowId"].ToString()!="")
					{
						model.PmFlowId=int.Parse(dt.Rows[n]["PmFlowId"].ToString());
					}
					if(dt.Rows[n]["NodeName"]!=null && dt.Rows[n]["NodeName"].ToString()!="")
					{
					model.NodeName=dt.Rows[n]["NodeName"].ToString();
					}
					if(dt.Rows[n]["DeafaultReceiveUserName"]!=null && dt.Rows[n]["DeafaultReceiveUserName"].ToString()!="")
					{
					model.DeafaultReceiveUserName=dt.Rows[n]["DeafaultReceiveUserName"].ToString();
					}
					if(dt.Rows[n]["DeafaultReceiveUserAccount"]!=null && dt.Rows[n]["DeafaultReceiveUserAccount"].ToString()!="")
					{
					model.DeafaultReceiveUserAccount=dt.Rows[n]["DeafaultReceiveUserAccount"].ToString();
					}
					if(dt.Rows[n]["DeafaultReceiveUseId"]!=null && dt.Rows[n]["DeafaultReceiveUseId"].ToString()!="")
					{
						model.DeafaultReceiveUseId=int.Parse(dt.Rows[n]["DeafaultReceiveUseId"].ToString());
					}
					if(dt.Rows[n]["ModifyForm"]!=null && dt.Rows[n]["ModifyForm"].ToString()!="")
					{
					model.ModifyForm=dt.Rows[n]["ModifyForm"].ToString();
					}
					if(dt.Rows[n]["State"]!=null && dt.Rows[n]["State"].ToString()!="")
					{
						model.State=int.Parse(dt.Rows[n]["State"].ToString());
					}
					if(dt.Rows[n]["PreState"]!=null && dt.Rows[n]["PreState"].ToString()!="")
					{
						model.PreState=int.Parse(dt.Rows[n]["PreState"].ToString());
					}
					if(dt.Rows[n]["NextState"]!=null && dt.Rows[n]["NextState"].ToString()!="")
					{
						model.NextState=int.Parse(dt.Rows[n]["NextState"].ToString());
					}
					if(dt.Rows[n]["PreBtValue"]!=null && dt.Rows[n]["PreBtValue"].ToString()!="")
					{
					model.PreBtValue=dt.Rows[n]["PreBtValue"].ToString();
					}
					if(dt.Rows[n]["NextBtValue"]!=null && dt.Rows[n]["NextBtValue"].ToString()!="")
					{
					model.NextBtValue=dt.Rows[n]["NextBtValue"].ToString();
					}
					if(dt.Rows[n]["NodeType"]!=null && dt.Rows[n]["NodeType"].ToString()!="")
					{
						model.NodeType=int.Parse(dt.Rows[n]["NodeType"].ToString());
					}
					if(dt.Rows[n]["ReceiveFormValue"]!=null && dt.Rows[n]["ReceiveFormValue"].ToString()!="")
					{
						model.ReceiveFormValue=int.Parse(dt.Rows[n]["ReceiveFormValue"].ToString());
					}
					if(dt.Rows[n]["ReceiveNodeValue"]!=null && dt.Rows[n]["ReceiveNodeValue"].ToString()!="")
					{
						model.ReceiveNodeValue=int.Parse(dt.Rows[n]["ReceiveNodeValue"].ToString());
					}
					if(dt.Rows[n]["HaveMsgNode"]!=null && dt.Rows[n]["HaveMsgNode"].ToString()!="")
					{
						model.HaveMsgNode=int.Parse(dt.Rows[n]["HaveMsgNode"].ToString());
					}
					if(dt.Rows[n]["DefaultMsgContent"]!=null && dt.Rows[n]["DefaultMsgContent"].ToString()!="")
					{
					model.DefaultMsgContent=dt.Rows[n]["DefaultMsgContent"].ToString();
					}
					if(dt.Rows[n]["HaveAttach"]!=null && dt.Rows[n]["HaveAttach"].ToString()!="")
					{
						model.HaveAttach=int.Parse(dt.Rows[n]["HaveAttach"].ToString());
					}
					if(dt.Rows[n]["CreateTime"]!=null && dt.Rows[n]["CreateTime"].ToString()!="")
					{
						model.CreateTime=DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
					}
					if(dt.Rows[n]["CreateUserId"]!=null && dt.Rows[n]["CreateUserId"].ToString()!="")
					{
						model.CreateUserId=int.Parse(dt.Rows[n]["CreateUserId"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

